<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html lang="en" style="overflow:hidden;">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title><spring:message code="sys.site.title" arguments="${platformName}"/></title>

		<meta name="description" content="overview &amp; stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

		<!-- 导入CSS -->
		<html:css  name="favicon,bootstrap,font-awesome,ace-theme,easy-ui"/>
	</head>

	<body class="no-skin">
		<!-- #section:basics/navbar.layout -->
		<div id="navbar" class="navbar navbar-default ace-save-state">
			 <%@include file="../ace/header.jsp"%>
		</div>
		<!-- /section:basics/navbar.layout -->
		<div class="main-container ace-save-state" id="main-container">
			<script type="text/javascript">
				try{ace.settings.loadState('main-container')}catch(e){}
				
			</script>
			<div class="easyui-layout" fit="true" id="cc" style="width:100%;">
			<!-- #section:basics/sidebar -->
			<div data-options="region:'west',split:true" style="width:195px;background-color:#354E69">
				<div id="sidebar" class="sidebar  responsive  ace-save-state">
					 <%@include file="../ace/left.jsp"%>
				</div>
			</div>
			<div data-options="region:'center'" style="overflow-x:hidden;">
				<div class="row content-tabs">
			                <button class="roll-nav roll-left J_tabLeft"><i class="fa fa-backward"></i>
			                </button>
			                <nav class="page-tabs J_menuTabs">
			                    <div class="page-tabs-content">
			                        <a href="javascript:;" class="active J_menuTab" data-id="${adminPath}/main">首页</a>
			                    </div>
			                </nav>
			                <button class="roll-nav roll-right J_tabRight"><i class="fa fa-forward"></i>
			                </button>
			                <div class="btn-group roll-nav roll-right">
			                    <button class="dropdown J_tabClose" data-toggle="dropdown">关闭操作<span class="caret"></span>
			
			                    </button>
			                    <ul role="menu" class="dropdown-menu dropdown-menu-right">
			                        <li class="J_tabShowActive"><a>定位当前选项卡</a>
			                        </li>
			                        <li class="divider"></li>
			                        <li class="J_tabCloseAll"><a>关闭全部选项卡</a>
			                        </li>
			                        <li class="J_tabCloseOther"><a>关闭其他选项卡</a>
			                        </li>
			                    </ul>
			                </div>
			                <%-- <a href="${adminPath}/logout" class="roll-nav roll-right J_tabExit"><i class="fa fa fa-sign-out"></i> 退出</a> --%>
			            </div>
			            <div class="row J_mainContent" id="content-main">
			                <iframe class="J_iframe" name="iframe0" width="100%" height="100%" src="${adminPath}/main" frameborder="0" data-id="${adminPath}/main" seamless></iframe>
			            </div>
			</div>
			<!-- /section:basics/sidebar -->

		</div><!-- /.main-container -->
		<!-- 全局js -->
		<html:js  name="jquery,bootstrap,metisMenu,slimscroll,layer,ace-theme,easy-ui"/>
		
		<script type="text/javascript" src="${staticPath}/common/js/contabs.js"></script>
		<script type="text/javascript">
			var firstName;
			var firstIcon;
			var changePwdTimes = "${fns:getUser().changePwdTimes}"
			var menus = new Array();
			$(function(){
				//首次登录修改密码
				setTimeout(function(){
				if(changePwdTimes==0){
						layer.open({
							 type: 2,  
							    area: ['400px', '260px'],
							    title: "修改密码(首次登录)",
						        maxmin: false, //开启最大化最小化按钮
							    content: '${adminPath}/sys/user/${fns:getUser().id}/changePassword',
							    btn: ['确定', '关闭(退出登录)'],
							    yes: function(index, layero){
							    	 var body = top.layer.getChildFrame('body', index);
							         var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
							         //文档地址
							         //http://www.layui.com/doc/modules/layer.html#use
							         iframeWin.contentWindow.doSubmit(
							         function(results) {
							        	 if(results.ret != 0) top.layer.alert(results.msg, {icon: 0, title:'警告'});
							        	 //判断逻辑并关闭
						       	         setTimeout(function(){top.layer.close(_index)}, 100);//延时0.1秒，对应360 7.1版本bug
							        	 window.location.reload();
							         });
									
								  },
								  cancel: function(index, layero){ 
									  if(confirm('首页登录需修改登录密码，否则将退出登录！确定要关闭么？')){ //只有当点击confirm框的确定时，该层才会关闭
										  window.location.href = "${adminPath}/logout";
									  }
									  return false; 
								  }  
						});
				}
				},500)
				$.ajax({
					type:"POST",
					url:"${adminPath}/menuJson",
					async:false,
					success:function(data){
						if(data.length==0){
							firstName = '控制台';
							firstIcon = 'fa-tachometer';
						}
						for(var i=0;i<data.length;i++){
							var tep ='';
							if(data[i].parentId == null && data[i].isshow == 1){
								if(!firstName){
									firstName = data[i].name;
									firstIcon = data[i].menuIcon;
								}
								for(var j =0;j<data.length;j++){
									if(data[j].parentId == data[i].id && data[j].isshow == 1){
										if(data[j].url != ''){
											tep += '<li><a class="J_menuItem" data-menuid="'+data[j].id+'" href="${adminPath}/'+data[j].url+'"><i class="menu-icon fa '+data[j].menuIcon+'" style="color:'+data[j].color+'"></i><span class="menu-text">'+data[j].name+'</span></a>';
										}else{
											tep += '<li><a href="#" class="dropdown-toggle"><i class="menu-icon fa '+data[j].menuIcon+'" style="color:'+data[j].color+'"></i><span class="menu-text">'+data[j].name+'</span><b class="arrow fa fa-angle-down"></b></a>';
										}
										tep +='<ul class="submenu">';
										for(var k =0;k<data.length;k++){
											if(data[k].parentId == data[j].id && data[k].isshow == 1){
												if(data[k].url != ''){
													tep += '<li><a class="J_menuItem" data-menuid="'+data[k].id+'" href="${adminPath}/'+data[k].url+'"><i class="menu-icon fa '+data[k].menuIcon+'" style="color:'+data[j].color+'"></i><span class="menu-text">'+data[k].name+'</span></a>';
												}else{
													tep += '<li><a href="#" class="dropdown-toggle"><i class="menu-icon fa '+data[k].menuIcon+'" style="color:'+data[j].color+'"></i><span class="menu-text">'+data[k].name+'</span><b class="arrow fa fa-angle-down"></b></a>';
												}
												tep +='<ul class="submenu">';
												for(var y =0;y<data.length;y++){
													if(data[y].parentId == data[k].id && data[y].isshow == 1){
														if(data[y].url != ''){
															tep += '<li><a class="J_menuItem" data-menuid="'+data[y].id+'" href="${adminPath}/'+data[y].url+'"><i class="menu-icon fa '+data[y].menuIcon+'" style="color:'+data[j].color+'"></i><span class="menu-text">'+data[y].name+'</span></a>';
														}else{
															tep += '<li><a href="#" class="dropdown-toggle"><i class="menu-icon fa '+data[y].menuIcon+'" style="color:'+data[j].color+'"></i><span class="menu-text">'+data[y].name+'</span><b class="arrow fa fa-angle-down"></b></a>';
														}
													}
												}
												tep +='</ul></li>';
											}
										}
										tep +='</ul></li>';
									}
									//TODO
								}
								menus.push(tep);
							}
						}
						
					},
					complete:function(d){
						$("#nav-list-ul").html(menus[0]);
						$("#sidebar-shortcuts").html('<i class="ace-icon fa '+firstIcon+'"></i>'+firstName);
						$('.J_menuItem').on('click', menuItem);
					}
				});
			});
			
		</script>
	</body>
</html>